package quatrecentvingtetun;

/**
 * Created by IntelliJ IDEA.
 * User: seeme
 * Date: 3 avr. 2009
 * Time: 03:43:37
 * To change this template use File | Settings | File Templates.
 */
public class Figure {
    private int score;
    private int niveau;
    private String figure;
    private int deMax;

    public int getScore(){
        return score;
    }

    public int getDeMax(){
        return deMax;
    }

    public int getNiveau(){
        return niveau;
    }

     public void setNiveau(int n){
        niveau=n;
    }

     public void setFigure(String s){
        figure=s;
        deMax = Character.getNumericValue(figure.charAt(0));
    }


    public String getFigure(){
        return figure;
    }

    public void setScore(int s){
        score=s;
    }

    public String toString(){
        return figure;
    }

    Figure(){
        score = 0;                               
        niveau = 0;
        deMax = 0;
        figure = "";
    }

    public boolean isBrelan(){
    if (figure.charAt(0)==figure.charAt(1) && figure.charAt(0)==figure.charAt(2)){
            return true;
    }
     else{
            return false;
    }
}

    public boolean is2As(){
        if( figure.charAt(1)==figure.charAt(2) && figure.charAt(2)=='1')
            return true;
         return false;
    }

    public boolean isSuite(){
        int car1=Character.getNumericValue(figure.charAt(0)); // comment convertir un char en entier ?

        int car2=Character.getNumericValue(figure.charAt(1));
        int car3=Character.getNumericValue(figure.charAt(2));


        if ( (car1-1== car2)  && ( car1-2==car3) ){
              return true;
        }
         else{
            return false;
         }

    }

    public void CalculScore(){
        if (figure.equals("421")){
              score=10;
              niveau = 1;
        }
          else{
             if(figure.equals("111")){
                 score=7;
                 niveau=2;
             }
             else{
                 if( isBrelan()==true || is2As()==true) {
                     score=Character.getNumericValue(figure.charAt(0));
                      niveau = 2;
                 }
                 else{
                     if(isSuite()==true){
                         score=2;
                         niveau = 3;
                     }
                     else{
                         if(figure=="221"){
                             score=4;
                             niveau = 4;
                         }
                         else{
                             score=1;
                             niveau = 5;
                         }

                     }
                 }

             }

        }
        deMax = Character.getNumericValue(figure.charAt(0));
    }




    Figure(String s){
        //Selon la chaine, on met les points et le niveau
        figure = s;
        CalculScore();
    }



}
